<?php
class V1_Store extends CI_Controller{
	 function __construct(){
	  	parent::__construct();
	 }
	 function thumb(){
	 	$this->load->library('upload',array('upload_path'=>'thumb/','allowed_types'=>'*','encrypt_name'=>true));
     	$output['code']=1001;
     	if($this->upload->do_upload('thumb')){
		 	$data=$this->upload->data();
		 	$output['code']=1000;
		 	$this->load->library('image_lib');
		 	$config['image_library']='gd2';
		 	$config['maintain_ratio']=false;
			$config['source_image']='thumb/'.$data['raw_name'].$data['file_ext'];//$data['file_ext']
			$config['quality']=100;$config['width']=45;$config['height']=45;
			$config['new_image']= 'thumb/'.$data['raw_name'].'_'.$config['width'].'_'.$config['height'].$data['file_ext'];
			$this->image_lib->initialize($config);
			$this->image_lib->resize();
			$T=getimagesize($config['source_image']);
			//$config['x_axis']=intval(($T[0]-180)/2);
			//$config['y_axis']=intval(($T[1]-125)/2);
			$config['width']=180;
			$config['height']=125;
			$config['new_image'] = 'thumb/'.$data['raw_name'].'_'.$config['width'].'_'.$config['height'].$data['file_ext'];
			$this->image_lib->clear();
			$this->image_lib->initialize($config);
			$this->image_lib->resize();
			//购物车:45*45,商品详情页:460*460,商品列表页:180*125
			$output['tag']=$data['raw_name'].$data['file_ext'];
		 	$output['thumb']='/thumb/'.$data['raw_name'].$data['file_ext'];
		}else{
			$output['msg']='错误的参数.';
		}
		json($output);
	 }
}
?>